﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DCEdu;
using System.Data;
using System.Globalization;

public partial class Tutor_Profile : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["id"] == null) return;

        TutorProfile tutor = new TutorProfile();
        DataSet dataSet = tutor.Get(Int32.Parse(Request.QueryString["id"]));
        if (dataSet == null) return;

        if (dataSet.Tables[0].Rows.Count < 0) return;
        
        ImgProfile.GenerateEmptyAlternateText = true;        
        ImgProfile.AlternateText = dataSet.Tables[0].Rows[0]["Image"].ToString();
        ImgProfile.ImageUrl = dataSet.Tables[0].Rows[0]["Image"].ToString();
        
        tbxName.Text = dataSet.Tables[0].Rows[0]["Name"].ToString();
        tbxTutorID.Text = dataSet.Tables[0].Rows[0]["ID"].ToString();
        tbxIDNumber.Text = dataSet.Tables[0].Rows[0]["IDNumber"].ToString();
        tbxGend.Text = dataSet.Tables[0].Rows[0]["Gender"].ToString();

        string pattern = "dd-MM-yyyy";
        DateTime parsedDate;
        String bday = dataSet.Tables[0].Rows[0]["Birthday"].ToString();
        if (DateTime.TryParseExact(bday, pattern, null, DateTimeStyles.AssumeLocal, out parsedDate))
        {
            tbxBirthday.Text = parsedDate.ToString("dd-MM-yyyy");
        }
        else
        {
            tbxBirthday.Text = bday;
        }

        tbxPhone.Text = dataSet.Tables[0].Rows[0]["Phone"].ToString();
        tbxEmail.Text = dataSet.Tables[0].Rows[0]["Email"].ToString();
        tbxEducation.Text = dataSet.Tables[0].Rows[0]["Education"].ToString();
        tbxUniversity.Text = dataSet.Tables[0].Rows[0]["University"].ToString();
        tbxSpecialize.Text = dataSet.Tables[0].Rows[0]["Specialize"].ToString();
        tbxJob.Text = dataSet.Tables[0].Rows[0]["Job"].ToString();
        tbxMark.Text = dataSet.Tables[0].Rows[0]["Mark"].ToString();
        tbxSubjects.Text = dataSet.Tables[0].Rows[0]["Subjects"].ToString();
        tbxClass.Text = dataSet.Tables[0].Rows[0]["Class"].ToString();
        tbxTransportation.Text = dataSet.Tables[0].Rows[0]["Transportation"].ToString();
        tbxExperience.Text = dataSet.Tables[0].Rows[0]["Experience"].ToString();
        tbxSalary.Text = dataSet.Tables[0].Rows[0]["Salary"].ToString();
        tbxPlace.Text = dataSet.Tables[0].Rows[0]["Place"].ToString();
        tbxTime.Text = dataSet.Tables[0].Rows[0]["Time"].ToString();
        tbxDescription.Text = dataSet.Tables[0].Rows[0]["Description"].ToString();
    }

    protected void btnContractRegister_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["id"] != null)
        {
            Response.Redirect("ContractRegister.aspx?id=" + Request.QueryString["id"] + "&type=Tutor");
        }
    }
}